home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / c_lang / strpp31.zip / FILESTR.CPP < prev    next >
C/C++ Source or Header  |  1994-04-18  |  1KB  |  59 lines

  1. /* -------------------------------------------------------------------- */
  2. /* String++ Version 3.10                                       04/13/94 */
  3. /*                                                                      */
  4. /* Enhanced string class for Turbo C++/Borland C++.                     */
  5. /* Copyright 1991-1994 by Carl W. Moreland                              */
  6. /*                                                                      */
  7. /* filestr.cpp                                                          */
  8. /* -------------------------------------------------------------------- */
  9.  
  10. #include "filestr.h"
  11.  
  12. FileString::FileString(const char* PathName)
  13. {
  14.   StrPP tmp = PathName;
  15.   Process(tmp);
  16. }
  17.  
  18. FileString::FileString(const StrPP& PathName)
  19. {
  20.   Process(PathName);
  21. }
  22.  
  23. void FileString::Process(const StrPP& PathName)
  24. {
  25.   int n;
  26.  
  27.   n = PathName.FindLast("\\");
  28.  
  29.   Path     = PathName.SubStr(0, n+1);
  30.   FileName = PathName.SubStr(n+1, PathName.Len()-n-1);
  31.  
  32.   n = FileName.FindLast(".");
  33.  
  34.   if(n != -1)
  35.   {
  36.     Name = FileName.SubStr(0, n);
  37.     Ext  = FileName.SubStr(n+1, FileName.Len()-n-1);
  38.   }
  39.   else
  40.     Name = FileName;
  41.  
  42.   if(Path[1] == ':')
  43.   {
  44.     Drive = Path.SubStr(0,2);
  45.     Path.Delete(0,2);
  46.   }
  47. }
  48.  
  49. void FileString::operator=(const char* PathName)
  50. {
  51.   StrPP tmp = PathName;
  52.   Process(tmp);
  53. }
  54.  
  55. void FileString::operator=(const StrPP& PathName)
  56. {
  57.   Process(PathName);
  58. }
  59.